package de.baumann.browser.activitys.node

import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import de.baumann.browser.OdinGlideModule
import de.baumann.browser.R
import de.baumann.browser.base.BaseOdinActivity
import de.baumann.browser.iview.IJoinVerifyView
import de.baumann.browser.present.JoinVerifyPresenter
import kotlinx.android.synthetic.main.activity_join_verify.*
import kotlinx.android.synthetic.main.include_tool_bar.*


/**
 *@author:
 *@date:2019/9/27 9:50
 *@discription: 加入请求审核
 */
@Deprecated("5.0.0版本之后活动结束，不再适用")
class JoinVerifyActivity : BaseOdinActivity<IJoinVerifyView, JoinVerifyPresenter>(), IJoinVerifyView {

    companion object {
        fun startJoinVerifyActivity(context: Context, applyId: String) {
            context.startActivity(Intent(context, JoinVerifyActivity::class.java).apply {
                putExtra("applyId", applyId)
            })
        }
    }

    override fun getTitleText(): String {
        return "用户详情"
    }

    override fun getLayout(): Int {
        return R.layout.activity_join_verify
    }

    override fun initView() {
        initToolbar(commToolBar,commTitle)
        btnJvPass.setOnClickListener {
            presenter.joinVerifyAction(1)
        }

        btnJvRefuse.setOnClickListener {
            presenter.joinVerifyAction(2)
        }
    }

    override fun createPresenter(): JoinVerifyPresenter {
        return JoinVerifyPresenter()
    }

    override fun createView(): IJoinVerifyView {
        return this
    }

    override fun initData() {
        presenter.joinVerify()
    }

    override fun getApplyId(): String {
        return intent.getStringExtra("applyId")
    }

    override fun setJvHead(url: String) {
        OdinGlideModule.loadWithCropAndCircle(mContext, url, ivJvHead, R.drawable.icon_head)
    }

    override fun setJvName(name: String) {
        tvJvName.text = name
    }

    @SuppressLint("SetTextI18n")
    override fun setJvHash(hash: String) {
        tvJvHash.text = "算力值:$hash"
    }

    @SuppressLint("SetTextI18n")
    override fun setJvTime(time: String) {
        tvJvJoinTime.text = "申请时间:$time"
    }

    override fun setJvNodeHash(nodeHash: String) {
        tvJVNodeHash.text = nodeHash
        progressJv.progress = nodeHash.toDouble().toInt()
    }

    @SuppressLint("SetTextI18n")
    override fun setJvProportion(proportion: String) {
        tvJvProportion.text = "(约占比$proportion)"
    }

    override fun verifyPass() {
        showShortToast("已通过")
        finish()
    }

    override fun verifyRefuse() {
        showShortToast("已拒绝")
        finish()
    }
}
